import Cookies from 'js-cookie'

const TokenKey = 'Admin-Token'
const UserKey = 'Admin-User'
const BackUrlKey = 'BackUrl'

export function getToken() {
	return Cookies.get(TokenKey)
}

export function setToken(token) {
	return Cookies.set(TokenKey, token)
}

export function removeToken() {
	return Cookies.remove(TokenKey)
}

export function getUserInfo() {
	let userInfo = Cookies.get(UserKey);
	if (userInfo) {
		return JSON.parse(userInfo)
	}
	return {};
}

export function setUserInfo(user) {
	return Cookies.set(UserKey, user)
}

export function removeUserInfo() {
	return Cookies.remove(UserKey)
}


export function setOAuthLoginBackUrl(url) {
	return Cookies.set(BackUrlKey, url)
}
export function getOAuthLoginBackUrl() {
	return Cookies.get(BackUrlKey)
}
